<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <script src="../js/vue.js"></script>
    <title>Document</title>
</head>
<body>
    <div id="app">
        <hello-world></hello-world>
        <hello-world></hello-world>
        <hello-world></hello-world>
    </div>
</body>
<script>
//新组件
/**
 *  注意
 *  1 data是个函数  返回{ }
 *  2 模版必须有根元素 
 *  3 template 最好用模版字符串` `
 */
Vue.component('hello-world',{
    data: function(){
        return {
            msg: 'chatGpt',
            n: 0 
        }
    },
    template:`
    <div>  
           <h1>组件测试  -- {{ msg }}</h1>
           <button @click='add'>按钮 {{ n }}</button>
    </div>
    `,
    methods:{
        add(){
            this.n++;
        }
    }
})


var vm = new Vue({
    el: "#app",
    data: {
        
    }
});

</script>
</html>